package com.teach;

import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public class Demo0101 {
	
	private static final ThreadLocalRandom r = ThreadLocalRandom.current();//多线程随机数 ;直译 : 线程本地随机数

	public static void main(String[] args) {
		for(int x=0;x<100;x++) {
			int blue = 0;
			int[] red = new int[6];
	//		Random r = new Random();
			
			blue = r.nextInt(16)+1;
//			loopi:for(int i=0;i<red.length;) {
//				red[i]=r.nextInt(33)+1;
//				for(int j=0;j<i;j++) {
//					if(red[j]==red[i]) {
//						continue loopi;
//					}
//				}
//				i++;
//			}
			randomIndex(red,0);
			
			Arrays.sort(red);
	
			System.out.println("蓝球:"+blue);
			System.out.println("红球:"+Arrays.toString(red));
		}
	}
	
	public static void randomIndex(int[] red,int i) {
		if(red.length <= i) {
			return;
		}
		red[i]=r.nextInt(33)+1;
		for (int j = 0; j < i; j++) {
			if (red[j] == red[i]) {
				randomIndex(red,i);
				return ;
			}
		}
		randomIndex(red,i+1);
	}
}
